
<script type="text/javascript" src="<?php echo base_url(); ?>public/js/bootstrap-typeahead.js"></script>

<?php
$sidebar =
        '<ul id=\"admin-nav\">
    <li><a href=\"' . site_url("admin/home") . '\">Admin kodu</a></li>
    <li><a href=\"' . site_url("admin/competitions") . '\">Võistlused</a></li>
    <li><a href=\"' . site_url("admin/competitions/manual") . '\">Käsitsi sisestamine</a></li>
    <li><a href=\"' . site_url("admin/tables") . '\">Aegade ja punktide tabelid</a></li>
</ul>';

$sidebar = str_replace("\n", '\n', $sidebar);
?> 

<?php if (isset($error)) echo "<div class=\"alert alert-error\">$error</div>" ?>
<?php echo validation_errors(); ?>

<link rel="stylesheet" type="text/css" href="<?php echo base_url() . 'public/css/dateinput.css'; ?>"/>

<?php
$my_var = <<<EOD
</form>
EOD;
?>

<style>

    .content-row {
        margin-top: 5px;
        margin-bottom: 5px;
    }

    #result, #entry {
        width: 90px;
    }

</style>
<script>
    $(".page-header").html("<h1>Administraatori lehekülg</h1>");
    $(".sidebar").html("<?php echo $sidebar; ?>");
    
    $(document).ready(function () {

        $("#competition").change(function() {
            window.location = "<?php echo site_url("admin/competitions/manual"); ?>" + "/" + $(this).val();
        });
        
    });

</script>

<?php

$competition_list[0] = "Vali võistlus";

foreach ($competitions as /* @var $competition Competition */ $competition) {
    $start = new DateTime($competition->getStartDate());
    $start = $start->format("d M Y");
    $end = new DateTime($competition->getEndDate());
    $end = $end->format("d M Y");
    $daterange = $start == $end ? $start : "$start - $end";
    $competition_list[$competition->getID()] = "$competition->name {$competition->pool}m ($daterange)";
}
?>

<div class="row content-row">
    <div class="col-md-8">
        <?php echo form_dropdown('competition', $competition_list, array(), 'id="competition" class="form-control"'); ?>
    </div>
    <div class="col-md-2">
        <a href="<?php echo site_url("admin/competitions/manual/new"); ?>" class="btn btn-default" role="button">
            <span class="glyphicon glyphicon-plus"></span> Lisa uus võistlus
        </a>
    </div>
</div>
